﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using Telerik.Web.UI;
using System.Globalization;
using System.Web.UI.HtmlControls;
using KPIS.Utils;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{ 
    public partial class WF_LoanAgreement : System.Web.UI.Page
    {
        private SsMng ssMng = new SsMng();
        private IEmployeeTypeBLL empTypeBLL = new EmployeeTypeBLL();


        protected void Page_Load(object sender, EventArgs e)
        {

            IncludeJava();
            if (!IsPostBack)
            {

                bindEmpType();

                //LoadDataGrid();
            }


        }
        private void bindEmpType()
        {
            try
            {
                IList<EmployeeTypeInfo> infoList = empTypeBLL.ListEmployeeTypes();
                ddlEmployeeType.DataSource = infoList;
                ddlEmployeeType.DataBind();

            }
            catch
            {

            }
        }
        public void LoadDataGrid(int EmpType)
        {

            try
            {


                DataTable dt;
                WelfareLoanAgreementBLL obj = new WelfareLoanAgreementBLL();
                dt = obj.Select(EmpType);

                RadGrid2.DataSource = dt;
                RadGrid2.DataBind();
            }
            catch (Exception ex)
            {

            }

        }

        public void IncludeJava()
        {
            HtmlGenericControl script = new HtmlGenericControl();
            script.TagName = "script";
            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", "../../Scripts/jsfunction.js");
            Page.Header.Controls.Add(script);
        }

        protected void RadGrid2_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {


            if (e.CommandName == "btnClick")
            {
                return;
            }

            if (e.CommandName == "Delete")
            {
                int seq = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cont_seq"]);

                WelfareLoanAgreementBLL obj = new WelfareLoanAgreementBLL();
                obj.Delete(seq, ssMng.EmpSeqI);
            }
            LoadDataGrid(Int32.Parse(ddlEmployeeType.SelectedValue));
        }

        protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
        {


        }


        protected void RadGrid2_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {

        }

        protected void ddlEmployeeType_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            LoadDataGrid(Int32.Parse(ddlEmployeeType.SelectedValue));
        }


        }    
}